package com.cognizant.ams.common.util;

import java.util.HashMap;
import java.util.Map;

/**
 * @author suyon
 * @date 2019-11-11 13:34
 */
public class CognizantResult extends HashMap<String, Object> {

	private static final long serialVersionUID = 1L;
	
	public CognizantResult() {
		put("code", 0000);
	}
	
	public static CognizantResult error() {
		return error(500, "未知异常，请联系管理员");
	}
	
	public static CognizantResult error(String msg) {
		return error(500, msg);
	}
	
	public static CognizantResult error(int code, String msg) {
		CognizantResult cognizantResult = new CognizantResult();
		cognizantResult.put("code", code);
		cognizantResult.put("msg", msg);
		return cognizantResult;
	}

	public static CognizantResult ok(String msg) {
		CognizantResult cognizantResult = new CognizantResult();
		cognizantResult.put("msg", msg);
		return cognizantResult;
	}
	
	public static CognizantResult ok(Map<String, Object> map) {
		CognizantResult cognizantResult = new CognizantResult();
		cognizantResult.putAll(map);
		return cognizantResult;
	}
	
	public static CognizantResult ok() {
		return new CognizantResult();
	}

	public CognizantResult put(String key, Object value) {
		super.put(key, value);
		return this;
	}
}
